package com.itheima.controller;

import com.itheima.pojo.Staff;
import com.itheima.service.StaffService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author huangbin
 * @date 2022/6/6 16:15
 */
@RestController
@RequestMapping("/staff")
public class StaffController {
    @Autowired
    private StaffService staffService;

    /**
     * 查询所有
     */
    @GetMapping
    public List<Staff> selectAll() {
        return staffService.selectAll();
    }

    /**
     * 查询单个
     */
    @GetMapping(value = "/{id}")
    Staff selectById(@Param("id") int id) {
        return staffService.selectById(id);
    }

    /**
     * 添加店铺
     */
    @PostMapping
    public Integer add(@RequestBody Staff staff) {
        return staffService.add(staff);
    }

    @DeleteMapping
    Integer del(int id) {
        return staffService.del(id);
    }

    @PutMapping
    Integer update(@RequestBody Staff staff) {
        return staffService.update(staff);
    }
}
